{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<style>
    .layui-td-gray{width: 100px}
</style>
<form class="layui-form p-4">
    <h3 class="pb-3">收益配置</h3>
    <table class="layui-table layui-table-form">
        <input type="hidden" name="id" value="{$id}">
        <tr>
            <td class="layui-td-gray">售酒端(%)</td>
            <td>
                <input type="text" name="rate_one" lay-verify="required" autocomplete="off" placeholder="请输入售酒端获得收益比例"
                       lay-reqText="请输入售酒端获得收益比例" class="layui-input" {notempty name="$config.rate_one" }
                       value="{$config.rate_one}" {/notempty} style="display: inline-block;">
            </td>
        </tr>
        <tr>
            <td class="layui-td-gray">售酒机管理员(%)</td>
            <td>
                <input type="text" name="rate_two" lay-verify="required" autocomplete="off" placeholder="请输入售酒机管理员获得收益比例"
                       lay-reqText="请输入售酒机管理员获得收益比例" class="layui-input" {notempty name="$config.rate_two" }
                       value="{$config.rate_two}" {/notempty} style="display: inline-block;">
            </td>
        </tr>
        <tr>
            <td class="layui-td-gray">补货员(%)</td>
            <td>
                <input type="text" name="rate_three" lay-verify="required" autocomplete="off" placeholder="请输入补货员获得收益比例"
                       lay-reqText="请输入补货员获得收益比例" class="layui-input" {notempty name="$config.rate_three" }
                       value="{$config.rate_three}" {/notempty} style="display: inline-block;">
            </td>
        </tr>
        <tr>
            <td class="layui-td-gray">自动结算时长(小时)</td>
            <td>
                <input type="text" name="hours" lay-verify="required" autocomplete="off" placeholder="请输入自动结算时长例"
                       lay-reqText="请输入自动结算时长例" class="layui-input" {notempty name="$config.hours" }
                       value="{$config.hours}" {/notempty} style="display: inline-block;">
            </td>
        </tr>
    </table>

    <div class="py-3">
        <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
</form>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
    const moduleInit = ['tool','tinymce'];
    function gouguInit() {
        var form = layui.form, tool = layui.tool;

        //上传缩略图
        var upload_thumb = layui.upload.render({
            elem: '#upload_btn_thumb',
            url: '/admin/api/upload',
            done: function (res) {
                //如果上传失败
                if (res.code == 1) {
                    return layer.msg('上传失败');
                }
                //上传成功
                $('#upload_box_thumb input').attr('value', res.data.filepath);
                $('#upload_box_thumb img').attr('src', res.data.filepath);
            }
        });

        //监听提交
        form.on('submit(webform)', function (data) {
            let callback = function (e) {
                layer.msg(e.msg);
                if (e.code == 0) {
                    parent.layui.tool.close(1000);
                }
            }
            tool.post("/admin/conf/edit", data.field, callback);
            return false;
        });
    }
</script>
{/block}
<!-- /脚本 -->